﻿package bdz.extensions.youtube.json.vo {
	
	/**
	 * ...
	 * @author Donald
	 */
	public class YTJSONFeedEntry {
		public var statistics:YTStatistics;
		public var categories:Array;
		public var title:String;
		public var publishedDate:Date;
		public var description:String;
		public var views:Number;
		public var duration:Number;
		public var keywords:String;
		public var thumbs:Array;
		public var player:String;
		public var id:String;
		public var microTime:Number;
		function YTJSONFeedEntry(obj:Object) {
			thumbs = new Array();
			categories = new Array();
			
			title = obj.title.$t;
			for each(var ytc:* in obj.category) {
				categories.push(new YTCategory(ytc));
			}
			
			try {
				var dtes:Array = obj.published.$t.split("T");
				publishedDate = new Date(dtes[0].split("-")[0], Number(dtes[0].split("-")[1])-1, dtes[0].split("-")[2], dtes[1].split(":")[0], dtes[1].split(":")[1], dtes[1].split(":")[2].split(".")[0]);
				microTime = publishedDate.getTime();
				description = obj.media$group.media$description.$t;
				keywords = obj.media$group.media$keywords.$t;
				trace(dtes);
				trace(publishedDate);
				for each(var tn:* in obj.media$group.media$thumbnail) {
					var tno:Object = { };
					for (var prop in tn) {
						tno[prop] = tn[prop];
					}
					thumbs.push(tno);
				}
				player = obj.media$group.media$player["0"].url;
				id = player.split("v=")[1].split("&")[0];
				
				duration = Number(obj.media$group.yt$duration.seconds);
				statistics = new YTStatistics(obj.yt$statistics);
				views = statistics.viewCount;
			}catch(e:Error){}
		}
	}
	
}